ostree.git
6 years agolib/repo: [scan-build] Quiet a dead store warning
Colin Walters [Fri, 18 Oct 2019 14:45:33 +0000 (14:45 +0000)]
lib/repo: [scan-build] Quiet a dead store warning

False positive, just add a pacifier.

6 years agotree-wide: [scan-build] Fix some dead stores
Colin Walters [Wed, 16 Oct 2019 19:36:31 +0000 (19:36 +0000)]
tree-wide: [scan-build] Fix some dead stores

No real issues, just quieting the scanner.

6 years agoMerge pull request #1945 from cgwalters/papr-trim
OpenShift Merge Robot [Wed, 16 Oct 2019 21:12:34 +0000 (23:12 +0200)]
Merge pull request #1945 from cgwalters/papr-trim

ci: Trim PAPR config to drop required flag

6 years agoMerge pull request #1943 from cgwalters/more-scan-build
OpenShift Merge Robot [Wed, 16 Oct 2019 18:44:15 +0000 (20:44 +0200)]
Merge pull request #1943 from cgwalters/more-scan-build

More scan build

6 years agoci: Trim PAPR config to drop required flag
Colin Walters [Wed, 16 Oct 2019 18:38:37 +0000 (18:38 +0000)]
ci: Trim PAPR config to drop required flag

Same as https://github.com/coreos/rpm-ostree/pull/1923
Quoting that rationale:

> Since we're not using Homu anymore (and Tide instead looks at
> all statuses by default), let's just drop it. This brings down the
> number of statuses on PRs by one more (and so one less context to
> override when needed).

6 years agoMerge pull request #1912 from akiernan/us-fix-trivial-httpd
OpenShift Merge Robot [Wed, 16 Oct 2019 18:15:56 +0000 (20:15 +0200)]
Merge pull request #1912 from akiernan/us-fix-trivial-httpd

Gate ostree-trivial-httpd on BUILDOPT_TRIVIAL_HTTPD

6 years agoMerge pull request #1937 from cgwalters/zipl-backend
OpenShift Merge Robot [Wed, 16 Oct 2019 15:21:10 +0000 (17:21 +0200)]
Merge pull request #1937 from cgwalters/zipl-backend

 bootloader: Add a zipl bootloader backend

6 years agoMerge pull request #1931 from cgwalters/covscan-fixes
OpenShift Merge Robot [Wed, 16 Oct 2019 15:05:31 +0000 (17:05 +0200)]
Merge pull request #1931 from cgwalters/covscan-fixes

libotutil: Port keyfile-utils.c to new style

6 years agoMerge pull request #1942 from cgwalters/build-installdeps
OpenShift Merge Robot [Wed, 16 Oct 2019 14:24:57 +0000 (16:24 +0200)]
Merge pull request #1942 from cgwalters/build-installdeps

ci: Skip all yum operations if SKIP_INSTALLDEPS is set

6 years agobootloader: Add a zipl bootloader backend
Colin Walters [Mon, 14 Oct 2019 19:22:19 +0000 (19:22 +0000)]
bootloader: Add a zipl bootloader backend

zipl is a bit special in that it parses the BLS config files
directly *but* we need to run the command to update the "boot block".

Hence, we're not generating a separate config file like the other
backends.  Instead, extend the bootloader interface with a `post_bls_sync`
method that is run in the same place we swap the `boot/loader` symlink.

We write a "stamp file" in `/boot` that says we need to run this command.
The reason we use stamp file is to prevent the case where the system is
interrupted after BLS file is updated, but before zipl is triggered,
then zipl boot records are not updated.
This opens the door to making things eventually-consistent/reconcilable
by later adding a systemd unit to run `zipl` if we're interrupted via
a systemd unit - I think we should eventually take this approach
everywhere rather than requiring `/boot/loader` to be a symlink.

Author: Colin Walters <walters@verbum.org>
Tested-by: Tuan Hoang <tmhoang@linux.ibm.com>
Co-Authored-By: Tuan Hoang <tmhoang@linux.ibm.com>
6 years agoprune: [scan-build] Initialize a variable
Colin Walters [Wed, 16 Oct 2019 13:48:20 +0000 (13:48 +0000)]
prune: [scan-build] Initialize a variable

Another false positive because we only read this if `opt_keep_younger_than` is `TRUE`,
but let's initialize variables on general principle.

6 years agotree-wide: [scan-build]: Add some asserts that pointers are non-NULL
Colin Walters [Wed, 16 Oct 2019 13:44:46 +0000 (13:44 +0000)]
tree-wide: [scan-build]: Add some asserts that pointers are non-NULL

More "scan-build doesn't understand GError and our out-param conventions"
AKA "these errors would be impossible with Rust's sum type Result<> approach".

6 years agocommit: [scan-build] Remove a dead assignment
Colin Walters [Wed, 16 Oct 2019 13:38:29 +0000 (13:38 +0000)]
commit: [scan-build] Remove a dead assignment

The `write_commit()` API defaults to current time, and
this assignment became dead in:
https://github.com/ostreedev/ostree/commit/8ba90a33410c9707a30a77f808a7ec712d465165

6 years agoci: Skip all yum operations if SKIP_INSTALLDEPS is set
Colin Walters [Wed, 16 Oct 2019 13:32:36 +0000 (13:32 +0000)]
ci: Skip all yum operations if SKIP_INSTALLDEPS is set

This is used by our OpenShift Prow job; we use the
cosa buildroot container:

https://github.com/coreos/coreos-assembler/pull/730

And using `yum` at all means we can flake on fetching rpm metadata.

6 years agolibotutil: Port keyfile-utils.c to new style
Colin Walters [Mon, 14 Oct 2019 13:19:28 +0000 (13:19 +0000)]
libotutil: Port keyfile-utils.c to new style

I was trying to fix a clang `scan-build` error that jlebon
ended up tracking down in
https://github.com/ostreedev/ostree/pull/1939/commits/9344de1ce1e8c185e01988277606ba1ed7f9d16b

But in the process of tracing through this I found it
way easier to read as "new style" code, so this also ports the
code.

I added a `g_assert()` in there too to help assert that
`g_key_file_get_value` won't leak in the error path.

6 years agoMerge pull request #1932 from cgwalters/covscan-fixes-2
OpenShift Merge Robot [Tue, 15 Oct 2019 17:56:54 +0000 (19:56 +0200)]
Merge pull request #1932 from cgwalters/covscan-fixes-2

libostree: Add an assert to pacify clang-analyzer

6 years agoMerge pull request #1939 from jlebon/pr/fix-keyfile-leak
OpenShift Merge Robot [Tue, 15 Oct 2019 17:13:56 +0000 (19:13 +0200)]
Merge pull request #1939 from jlebon/pr/fix-keyfile-leak

src/libotutil: Fix strv memory leak

6 years agosrc/libotutil: Fix strv memory leak
Jonathan Lebon [Tue, 15 Oct 2019 15:56:34 +0000 (11:56 -0400)]
src/libotutil: Fix strv memory leak

We were only freeing the array and not the members.

Caught by `clang-analyzer` in:
https://github.com/ostreedev/ostree/pull/1931

6 years agoMerge pull request #1933 from cgwalters/scan-build-0
OpenShift Merge Robot [Tue, 15 Oct 2019 15:59:00 +0000 (17:59 +0200)]
Merge pull request #1933 from cgwalters/scan-build-0

A few more scan-build fixes

6 years agorepo: [scan-build]: Mark a variable used
Colin Walters [Mon, 14 Oct 2019 14:24:18 +0000 (14:24 +0000)]
repo: [scan-build]: Mark a variable used

We're just using this to auto-free, quiet the static analysis.

6 years agosysroot: [scan-build] Remove a dead assignment
Colin Walters [Mon, 14 Oct 2019 14:22:12 +0000 (14:22 +0000)]
sysroot: [scan-build] Remove a dead assignment

Just quieting the scan.

6 years agosysroot: [scan-build]: Remove a dead assignment
Colin Walters [Mon, 14 Oct 2019 14:20:44 +0000 (14:20 +0000)]
sysroot: [scan-build]: Remove a dead assignment

Clarify the conditionals here and remove a dead assignment.

6 years agorepo: [scan-build] Initialize a variable
Colin Walters [Mon, 14 Oct 2019 14:17:09 +0000 (14:17 +0000)]
repo: [scan-build] Initialize a variable

Another GLib error convention issue; but eh, we might as
well be conservative and always initialize variables.

6 years agolibostree: Add an assert to pacify clang-analyzer
Colin Walters [Mon, 14 Oct 2019 13:25:46 +0000 (13:25 +0000)]
libostree: Add an assert to pacify clang-analyzer

Got this error when trying to rebase libostree in RHEL:

```
Error: CLANG_WARNING: [#def1]
libostree-2019.2/src/libostree/ostree-repo-checkout.c:375:21: warning: Access to field 'disable_xattrs' results in a dereference of a null pointer (loaded from variable 'repo')
```

I think what's happening is it sees us effectively testing
`if (repo == NULL)` via the `while (current_repo)`.  Let's
tell it we're sure it's non-null right after the loop.

6 years agoMerge pull request #1938 from cgwalters/owners-file
Colin Walters [Mon, 14 Oct 2019 20:29:05 +0000 (16:29 -0400)]
Merge pull request #1938 from cgwalters/owners-file

OWNERS: New file

6 years agoOWNERS: New file
Colin Walters [Mon, 14 Oct 2019 19:47:23 +0000 (19:47 +0000)]
OWNERS: New file

I tried to balance reflecting the reality of who works on libostree
today with keeping some of the existing committers - particularly
committers from multiple organizations.

Part of switching libostree over to OpenShift Prow.

6 years agoMerge pull request #1934 from cgwalters/mkdir-artifacts
Colin Walters [Mon, 14 Oct 2019 14:59:31 +0000 (10:59 -0400)]
Merge pull request #1934 from cgwalters/mkdir-artifacts

ci: Make ${ARTIFACTS} directory

6 years agoci: Make ${ARTIFACTS} directory
Colin Walters [Mon, 14 Oct 2019 14:29:31 +0000 (14:29 +0000)]
ci: Make ${ARTIFACTS} directory

It may not exist in OpenShift Prow by default.

6 years agoci: Honor ARTIFACTS environment variable
Colin Walters [Fri, 11 Oct 2019 20:25:48 +0000 (20:25 +0000)]
ci: Honor ARTIFACTS environment variable

This is set by the OpenShift Prow pod-utils:
https://github.com/openshift/test-infra/blob/master/prow/pod-utilities.md

Prep for having OSTree use that.

Closes: #1930
Approved by: jlebon

6 years agoGate ostree-trivial-httpd on BUILDOPT_TRIVIAL_HTTPD
Alex Kiernan [Thu, 5 Sep 2019 12:22:15 +0000 (13:22 +0100)]
Gate ostree-trivial-httpd on BUILDOPT_TRIVIAL_HTTPD

When building without --enable-trivial-httpd-cmdline, don't build or install
the ostree-trivial-httpd binary.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
6 years agoAlways enable trivial-httpd for tests
Alex Kiernan [Wed, 4 Sep 2019 16:29:15 +0000 (17:29 +0100)]
Always enable trivial-httpd for tests

When running tests we always need ostree-trivial-httpd, so enable it
unconditionally

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
6 years agogrub2: Exit gracefully if the configuration has BLS enabled
Javier Martinez Canillas [Thu, 26 Sep 2019 15:33:57 +0000 (17:33 +0200)]
grub2: Exit gracefully if the configuration has BLS enabled

Since Fedora 30 grub2 has support to populate its menu entries from the
BootLoaderSpec fragments in /boot/loader/entries, so there's no need to
generate menu entries anymore using the /etc/grub.d/15_ostree script.

But since ostree doesn't update the bootloader, it may be that the grub2
installed is an old one that doesn't have BLS support.

For new installs, GRUB_ENABLE_BLSCFG=true is set in /etc/default/grub to
tell the /etc/grub.d/10_linux script if a blscfg command has to be added
to the generated grub2 config file.

So check if BLS is enabled in /etc/default/grub and only add the entries
if that's not the case. Otherwise the menu entries will be duplicated.

The approach has the drawback that if a user sets GRUB_ENABLE_BLSCFG=true
in /etc/default/grub without updating grub2, they will get an empty menu.
Since there won't be any entries created by the 30_ostree script and the
blscfg command won't work on the older grub2.

Unfortunately there is no way to know if the installed grub2 already has
BLS support or not.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1751272#c27

Closes: #1929
Approved by: jlebon

6 years agoconfigure.ac: Add more details on how to do a release
Jonathan Lebon [Wed, 25 Sep 2019 15:27:38 +0000 (11:27 -0400)]
configure.ac: Add more details on how to do a release

Closes: #1928
Approved by: cgwalters

6 years agoPost-release version bump
Jonathan Lebon [Wed, 25 Sep 2019 13:39:19 +0000 (09:39 -0400)]
Post-release version bump

Closes: #1927
Approved by: cgwalters

6 years agoRelease 2019.4
Jonathan Lebon [Wed, 25 Sep 2019 13:37:48 +0000 (09:37 -0400)]
Release 2019.4

Tiny release. Just want to get out the important bugfixes instead of
backporting patches (notably the gpg-agent stuff and
`ostree-finalize-staged.service` ordering).

Closes: #1927
Approved by: cgwalters

6 years agoboot/finalize-staged: Run after systemd-journal-flush.service
Jonathan Lebon [Tue, 24 Sep 2019 21:08:54 +0000 (17:08 -0400)]
boot/finalize-staged: Run after systemd-journal-flush.service

In Fedora 31, `systemd-journal-flush.service` uses a new
`--smart-relinquish-var` switch which fixes the
`umount: /var: target is busy` bug by telling journald to stop logging
to `/var` and back to `/run` again during shutdown.

This interacted with `ostree-finalize-staged.service` in a tricky way:
since we weren't strongly ordered against it, when we happened to
finalize after `/var` is relinquished, we never persisted the output
from that service to disk. This then threw off `rpm-ostree status` when
trying to find the completion message to know that finalization went
well.

Just fix this by adding an explicit `After=` on that unit. That way we
shut down *before* `systemd-journal-flush.service` (the `/var`
relinquish bit happens in its `ExecStop=`).

For more info, see:
https://github.com/systemd/systemd/commit/3ff7a50d66e3f851d3d9f132b740a7fb2055aa1d
https://github.com/systemd/systemd/commit/1e187d2dd52cbb4f0bb30e4d96acf7f72a145b91
https://bugzilla.redhat.com/show_bug.cgi?id=1751272

Closes: #1926
Approved by: cgwalters

6 years agolib/repo-pull: Add more debugging on pull failure
Philip Withnall [Mon, 21 May 2018 15:01:13 +0000 (16:01 +0100)]
lib/repo-pull: Add more debugging on pull failure

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1925
Approved by: cgwalters

6 years agoprepare-root: remember to remove /sysroot.tmp
Benjamin Gilbert [Fri, 13 Sep 2019 06:37:01 +0000 (02:37 -0400)]
prepare-root: remember to remove /sysroot.tmp

Without this, rerunning ostree-prepare-root will fail in mkdir()
because /sysroot.tmp already exists, which complicates debugging from
the dracut emergency shell.

Closes: #1919
Approved by: cgwalters

6 years agofsck: Fix version in docs, tweak error text
Colin Walters [Mon, 9 Sep 2019 14:23:20 +0000 (14:23 +0000)]
fsck: Fix version in docs, tweak error text

I think this error message is clearer.

Closes: #1918
Approved by: jlebon

6 years agofsck: Add test for --delete corruption, fix repair, and partial commit checks
Jason Wessel [Wed, 10 Jul 2019 18:42:27 +0000 (14:42 -0400)]
fsck: Add test for --delete corruption, fix repair, and partial commit checks

The ostree fsck test is aimed to check that it will still fail an fsck
if the repository has been repaired by fsck.  It also checks that a
pull operation corrects the error and ostree fsck will exit with zero.

The test was modeled after the following script:

rm -rf ./f1
mkdir -p ./f1
./ostree --repo=./f1 init --mode=archive-z2
mkdir -p ./trial
echo test > ./trial/test
./ostree --repo=./f1 commit --tree=dir=./trial --skip-if-unchanged --branch=exp1 --subject="test Commit"

rm -rf ./f2
mkdir -p ./f2
./ostree --repo=./f2 init
./ostree --repo=./f2 pull-local  ./f1

echo whoops > `find ./f2 |grep objects |grep \\.file `
./ostree fsck --repo=./f2 ; echo Exit: $?
./ostree fsck --delete --repo=./f2 ; echo Exit: $?
./ostree fsck --repo=./f2 ; echo Exit: $?
./ostree --repo=./f2 pull-local  ./f1
./ostree fsck --repo=./f2 ; echo Exit: $?

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
fsck: Update test so that it will pass on fs without xattrs

The fsck test does not require xattrs to prove that it works.  It is
simple enough to change it to use an archvie instead of a bare type
repository.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Closes: #1910
Approved by: cgwalters

6 years agofsck: Implement a partial commit reason bitmask
Jason Wessel [Wed, 10 Jul 2019 18:47:27 +0000 (14:47 -0400)]
fsck: Implement a partial commit reason bitmask

After the corruption has been fixed with "ostree fsck -a --delete", a
second run of the "ostree fsck" command will print X partial commits
not verified and exit with a zero.

The zero exit code makes it hard to detect if a repair operation needs
to be run.  When ever fsck creates a partial commit it should add a
reason for the partial commit to the state file found in
state/<hash>.commitpartial.  This will allow a future execution of the
fsck to still return an error indicating that the repository is still
in the damaged state, awaiting repair.

Additional reason codes could be added in the future for why a partial
commit exists.

Text from: https://github.com/ostreedev/ostree/pull/1880
====
cgwalters commented:

To restate, the core issue is that it's valid to have partial commits
for reasons other than fsck pruned bad objects, and libostree doesn't
have a way to distinguish.

Another option perhaps is to write e.g. fsck-partial into the
statefile state/<hash>.commitpartial which would mean "partial, and
expected to exist but was pruned by fsck" and fsck would continue to
error out until the commit was re-pulled. Right now the partial stamp
file is empty, so it'd be fully compatible to write a rationale into
it.
====

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Closes: #1910
Approved by: cgwalters

6 years agolib/gpg: Use g_spawn_sync to kill gpg-agent
Dan Nicholson [Fri, 6 Sep 2019 22:52:15 +0000 (16:52 -0600)]
lib/gpg: Use g_spawn_sync to kill gpg-agent

For reasons I don't understand, GSubprocess doesn't play nice with KDE's
plasmashell. I assume this has something to do with the GSubprocess
using the glib worker thread while plasmashell uses the glib main
loop. Instead, just use g_spawn_sync to fork and wait in the current
thread.

Fixes: #1913
Closes: #1917
Approved by: cgwalters

6 years agolib/gpg: Don't kill gpg-agent on newer gnupg
Dan Nicholson [Thu, 5 Sep 2019 18:20:04 +0000 (12:20 -0600)]
lib/gpg: Don't kill gpg-agent on newer gnupg

GnuPG 2.1.17 contains a bug fix so that `gpg-agent` is killed when the
entire GPG home directory is deleted[1]. If the host's GnuPG is new
enough, then we don't need to bother calling `gpg-connect-agent` to kill
the agent since it will be cleaned up on its own.

Get the GnuPG version from the GPGME OpenPGP engine info and parse it to
see if it matches this criteria.

1. https://dev.gnupg.org/T2756

Closes: #1915
Approved by: cgwalters

6 years agolib/gpg: Only show gpg-connect-agent stderr on failures
Dan Nicholson [Fri, 16 Aug 2019 04:24:54 +0000 (22:24 -0600)]
lib/gpg: Only show gpg-connect-agent stderr on failures

When listing GPG keys, the temporary GPG homedir will be constructed by
simply copying the remote's trusted keys to the pubring.gpg file. In
that case, no GPG operations spawning gpg-agent will be run. When
gpg-connect-agent is run to cleanup the homedir, it will helpfully print
on stderr that it's starting gpg-agent like so:

gpg-connect-agent: no running gpg-agent - starting '/usr/bin/gpg-agent'
gpg-connect-agent: waiting for the agent to come up ... (5s)
gpg-connect-agent: connection to agent established

Send gpg-connect-agent's stderr to a pipe and only send it to the
application's stderr if an error was encountered.

Fixes: #1907
Closes: #1908
Approved by: cgwalters

6 years agolib/bootconfig-parser: Always include deployment index in BLS title
Javier Martinez Canillas [Mon, 2 Sep 2019 09:36:12 +0000 (11:36 +0200)]
lib/bootconfig-parser: Always include deployment index in BLS title

If there are different deployments for the same commit version, the BLS
snippets will have the same title fields (but different version fields):

$ grep title *
ostree-1-testos.conf:title TestOS 42 20190902.0 (ostree)
ostree-2-testos.conf:title TestOS 42 20190902.0 (ostree)
ostree-3-testos.conf:title TestOS 42 20190902.0 (ostree)

But bootloaders could expect the title field to be unique for BLS files.
For example, the zipl bootloader used in the s390x architecture uses the
field to name the boot sections that are created from the BLS snippets.

So two BLS snippets having the same title would lead to zipl failing to
create the IPL boot sections because they would have duplicated names:

$ zipl
Using config file '/etc/zipl.conf'
Using BLS config file '/boot/loader/entries/ostree-3-testos.conf'
Using BLS config file '/boot/loader/entries/ostree-2-testos.conf'
Using BLS config file '/boot/loader/entries/ostree-1-testos.conf'
Error: Config file '/etc/zipl.conf': Line 0: section name 'TestOS 42 20190902.0 (ostree)' already specified

Avoid this by always including the deployment index along with the commit
version in the title field, so this will be unique even if there are BLS
files for deployments that use the same commit version:

$ grep title *
ostree-1-testos.conf:title TestOS 42 20190902.0 (ostree:2)
ostree-2-testos.conf:title TestOS 42 20190902.0 (ostree:1)
ostree-3-testos.conf:title TestOS 42 20190902.0 (ostree:0)

$ zipl
Using config file '/etc/zipl.conf'
Using BLS config file '/boot/loader/entries/ostree-3-testos.conf'
Using BLS config file '/boot/loader/entries/ostree-2-testos.conf'
Using BLS config file '/boot/loader/entries/ostree-1-testos.conf'
Building bootmap in '/boot'
Building menu 'zipl-automatic-menu'
Adding #1: IPL section 'TestOS 42 20190902.0 (ostree:0)' (default)
Adding #2: IPL section 'TestOS 42 20190902.0 (ostree:1)'
Adding #3: IPL section 'TestOS 42 20190902.0 (ostree:2)'
Preparing boot device: dasda (0120).
Done.

Closes: #1911
Approved by: cgwalters

6 years agolib/bootconfig-parser: Write BLS fragment fields in a deterministic order
Javier Martinez Canillas [Tue, 27 Aug 2019 00:12:29 +0000 (02:12 +0200)]
lib/bootconfig-parser: Write BLS fragment fields in a deterministic order

Currently the BLS fragments fields write is non-determinisitc. The order
of the fields will depend on how the iterator of the options GHashTable
iterates over the key/value pairs.

But some bootloaders expect the fields to be written in a certain order.
For example the zipl bootloader (used in the s390x architecture) fails to
parse BLS files if the first field is not the 'title' field, since that's
used to name the zipl boot sections that are created from the BLS files.

Write the fields in a deterministic order, following what is used in the
example file of the BootLoaderspec document:

https://systemd.io/BOOT_LOADER_SPECIFICATION

Related: https://github.com/ostreedev/ostree/issues/1888

Closes: #1904
Approved by: cgwalters

6 years agolib/bootconfig-parser: Remove support to preserve comments in BLS files
Javier Martinez Canillas [Tue, 27 Aug 2019 00:12:19 +0000 (02:12 +0200)]
lib/bootconfig-parser: Remove support to preserve comments in BLS files

OSTree has some logic to preserve comment lines in the BLS fragments, but
the BLS fragments are always created on new deployments so the comments
are never carried.

Also, OSTree never writes BLS fragments with comments so these will only
be present in BLS files that were modified outside of OSTree. Something
that should be avoided in general.

Finally, there is a bug in the logic that causes BLS files to have lines
with only a newline character.

The ostree_bootconfig_parser_parse_at() function reads the bootconfig file
using glnx_fd_readall_utf8() but this function NUL terminates the returned
string with the file contents.

So when the string is later split using '\n' as delimiter, the last token
is set to '\0' and a wrong GVariant will be added to the lines GPtrArray
in the OstreeBootconfigParser struct.

This will lead to bootconfig files that contains lines with only a newline
character, since the key in the GVariant would be set to NUL and won't be
present in the options GHashTable of the OstreeBootconfigParser struct.

So let's just remove that logic since is never used and makes BLS files to
have wrong empty lines.

Before this patch:

$ tail -n 4 /boot/loader/entries/ostree-1-testos.conf | hexdump -C
00000000  74 69 74 6c 65 20 54 65  73 74 4f 53 20 34 32 20  |title TestOS 42 |
00000010  32 30 31 39 30 38 32 34  2e 30 20 28 6f 73 74 72  |20190824.0 (ostr|
00000020  65 65 29 0a 0a 0a 0a                              |ee)....|
00000027

After this patch:

$ tail -n 4 /boot/loader/entries/ostree-1-testos.conf | hexdump -C
00000000  76 65 72 73 69 6f 6e 20  31 0a 6f 70 74 69 6f 6e  |version 1.option|
00000010  73 20 72 6f 6f 74 3d 4c  41 42 45 4c 3d 4d 4f 4f  |s root=LABEL=MOO|
00000020  20 71 75 69 65 74 20 6f  73 74 72 65 65 3d 2f 6f  | quiet ostree=/o|
00000030  73 74 72 65 65 2f 62 6f  6f 74 2e 31 2f 74 65 73  |stree/boot.1/tes|
00000040  74 6f 73 2f 61 65 34 36  34 39 36 38 30 64 33 65  |tos/ae4649680d3e|
00000050  38 33 62 32 34 65 34 37  66 38 64 66 31 30 38 31  |83b24e47f8df1081|
00000060  38 62 66 36 39 38 39 64  36 34 37 61 62 32 38 38  |8bf6989d647ab288|
00000070  64 31 63 30 39 38 30 36  65 34 61 33 36 61 34 65  |d1c09806e4a36a4e|
00000080  62 62 66 36 2f 30 0a 6c  69 6e 75 78 20 2f 6f 73  |bbf6/0.linux /os|
00000090  74 72 65 65 2f 74 65 73  74 6f 73 2d 61 65 34 36  |tree/testos-ae46|
000000a0  34 39 36 38 30 64 33 65  38 33 62 32 34 65 34 37  |49680d3e83b24e47|
000000b0  66 38 64 66 31 30 38 31  38 62 66 36 39 38 39 64  |f8df10818bf6989d|
000000c0  36 34 37 61 62 32 38 38  64 31 63 30 39 38 30 36  |647ab288d1c09806|
000000d0  65 34 61 33 36 61 34 65  62 62 66 36 2f 76 6d 6c  |e4a36a4ebbf6/vml|
000000e0  69 6e 75 7a 2d 33 2e 36  2e 30 0a 74 69 74 6c 65  |inuz-3.6.0.title|
000000f0  20 54 65 73 74 4f 53 20  34 32 20 32 30 31 39 30  | TestOS 42 20190|
00000100  38 32 34 2e 30 20 28 6f  73 74 72 65 65 29 0a     |824.0 (ostree).|
0000010f

Closes: #1904
Approved by: cgwalters

6 years agoci: Add prow/ subdirectory with Dockerfile
Colin Walters [Wed, 28 Aug 2019 18:59:10 +0000 (18:59 +0000)]
ci: Add prow/ subdirectory with Dockerfile

I'd like to add OpenShift's prow to this repository.  Let's start
by adding a Dockerfile - it doesn't really do anything besides build.

However...I've lately been thinking about e.g. shipping the ostree tests
as an image, and then e.g. we could test FCOS by running that container
(which would orchestrate the *host's* ostree).

Anyways, not doing that right now but this is a start.

Also this cherry picks the fix from rpm-ostree CI for the sad
Fedora release package brokenness.

Closes: #1906
Approved by: cgwalters

6 years agosysroot: Add a clearer error if /boot/loader isn't found
Colin Walters [Mon, 26 Aug 2019 17:43:26 +0000 (17:43 +0000)]
sysroot: Add a clearer error if /boot/loader isn't found

I've seen people confused by this error in the case where
`/boot` isn't mounted or the BLS fragments were deleted, etc.
If you understand ostree deeply it's clear but, let's do
better here and a direct error message for the case where
we can't find `/boot/loader` which is the majority of these.

The other case could happen if e.g. just the BLS fragment
for the booted deployment was deleted; let's reword that
one a bit too.

Closes: #1905
Approved by: rfairley

6 years agoPost-release version bump
Colin Walters [Thu, 22 Aug 2019 18:06:53 +0000 (18:06 +0000)]
Post-release version bump

Closes: #1902
Approved by: rfairley

6 years agoRelease 2019.3
Colin Walters [Thu, 22 Aug 2019 18:04:40 +0000 (18:04 +0000)]
Release 2019.3

It's been a while, and we need the new kargs API for rpm-ostree.

Closes: #1902
Approved by: rfairley

6 years agolib/deploy: handle FIFREEZE ENOSYS failure
Daniel Drake [Wed, 21 Aug 2019 06:42:48 +0000 (14:42 +0800)]
lib/deploy: handle FIFREEZE ENOSYS failure

When running under qemu, unimplemented ioctls such as FIFREEZE
return ENOSYS, and this causes the deployment to fail.

Catch this and handle it like EOPNOTSUPP.

I'm not sure if qemu's behaviour is fully correct here (or if it should
return EOPNOTSUPP) but it's trivial to handle regardless.

Closes: #1901
Approved by: cgwalters

6 years agobin: Better handle --
Jonathan Lebon [Tue, 13 Aug 2019 19:05:09 +0000 (15:05 -0400)]
bin: Better handle --

We would stop passing through `--` and args after it to the underlying
command in `ostree_run`. This made it impossible to use `--` to tell the
parser that following args starting with `-` really are positional.

AFAICT, that logic for `--` here came from a time when we parse options
manually in a big loop, in which case breaking out made sense (see
97558276e4f855442337be01abc8f90cf0dd1810).

There's an extra step here, which is that glib by default leaves the
`--` in the list of args, so we need to take care to remove it from the
list after parsing.

Closes: #1898
Closes: #1899
Approved by: rfairley

6 years agoadmin/init-fs: Add a --modern switch
Colin Walters [Tue, 6 Aug 2019 01:59:38 +0000 (01:59 +0000)]
admin/init-fs: Add a --modern switch

This skips creating the default stuff in the physical sysroot.
I don't recall why I did that to be honest; it originated with
the first commit of this file.  It might not have ever been
necessary.

In any case, it's not necessary now with Fedora CoreOS, so
prune it and let's have a clean `/`.

Keep the old behavior by default though to avoid breaking anyone.

Closes: #1894
Approved by: ajeddeloh

6 years agoREADME.md: Rework "projects using" section
Colin Walters [Wed, 7 Aug 2019 11:40:02 +0000 (11:40 +0000)]
README.md: Rework "projects using" section

Update this to mention the 3 Fedora derivatives, RHEL CoreOS etc.

Create 3 sections:

 - OS/Distributions
 - build tools
 - rpm-ostree/flatpak

Closes: #1895
Approved by: dustymabe

6 years agotests/test-repo-finder-mount: skip some tests if GPG is not supported
Denis Pynkin [Mon, 29 Jul 2019 23:42:43 +0000 (02:42 +0300)]
tests/test-repo-finder-mount: skip some tests if GPG is not supported

`ostree_repo_resolve_keyring_for_collection()` function fail the tests
if there is no GPG support.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
Closes: #1889
Approved by: cgwalters

6 years agotests/gpg: fix GPG-dependent shell tests if no GPG support
Denis Pynkin [Mon, 29 Jul 2019 23:39:12 +0000 (02:39 +0300)]
tests/gpg: fix GPG-dependent shell tests if no GPG support

Skip tests or run them without GPG-related functionality if GPGME
wasn't enabled in a build time.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
Closes: #1889
Approved by: cgwalters

6 years agotests/gpg: fix the check of GPG support
Denis Pynkin [Mon, 29 Jul 2019 23:16:57 +0000 (02:16 +0300)]
tests/gpg: fix the check of GPG support

Shell function `has_gpgme` shouldn't exit if GPG support is not detected
since it stop any test with error.

Added function `skip_without_gpgme` to skip the whole test if it is
useless without GPG support

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
Closes: #1889
Approved by: cgwalters

6 years agogpg: add dummy public interface
Denis Pynkin [Sun, 21 Jul 2019 20:40:32 +0000 (23:40 +0300)]
gpg: add dummy public interface

Add dummy stubs for GPG public functions to be compiled instead of
original code in case if support of GPG is disabled.
Need that to keep API backward compatibility.

Based on original code from file `ostree-gpg-verify-result.c`.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
Closes: #1889
Approved by: cgwalters

6 years agolib: rename common sign/verification functions and variables
Denis Pynkin [Thu, 18 Jul 2019 16:08:21 +0000 (19:08 +0300)]
lib: rename common sign/verification functions and variables

Some gpg-named functions/variables should be used for any signature
system, so remove "gpg_" prefix from them to avoid confusion.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
Closes: #1889
Approved by: cgwalters

6 years agogpg: conditionally build GPG-related code for sign/verification
Denis Pynkin [Mon, 20 May 2019 22:35:25 +0000 (01:35 +0300)]
gpg: conditionally build GPG-related code for sign/verification

Do not build the code related to GPG sign and verification if
GPGME support is disabled.
Public functions return error 'G_IO_ERROR_NOT_SUPPORTED' in case if
gpg-related check is rquested.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
Closes: #1889
Approved by: cgwalters

6 years agobuild: Conditionally build the GPG-related tests
Denis Pynkin [Mon, 20 May 2019 22:23:14 +0000 (01:23 +0300)]
build: Conditionally build the GPG-related tests

Do not build GPG signing/verification tests if `--without-gpgme`
option is used during configuration.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
Closes: #1889
Approved by: cgwalters

6 years agobuild: Conditionally build GPGME-related sources
Denis Pynkin [Sun, 19 May 2019 13:47:45 +0000 (16:47 +0300)]
build: Conditionally build GPGME-related sources

Do not build GPGME-related sources if flag USE_GPGME is not defined.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
Closes: #1889
Approved by: cgwalters

6 years agobuild: Add conditional use of GPGME
Denis Pynkin [Sun, 19 May 2019 13:24:40 +0000 (16:24 +0300)]
build: Add conditional use of GPGME

Allow to disable GPGME support with option "--without-gpgme" for
configure.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
Closes: #1889
Approved by: cgwalters

6 years agolib/pull: Rename variable for clarity
Jonathan Lebon [Fri, 26 Jul 2019 15:52:27 +0000 (11:52 -0400)]
lib/pull: Rename variable for clarity

Let's use `checksum` instead of the more general `contents`.

Closes: #1891
Approved by: cgwalters

6 years agolib/pull: Allow downgrade protection with overrides
Jonathan Lebon [Fri, 26 Jul 2019 15:52:18 +0000 (11:52 -0400)]
lib/pull: Allow downgrade protection with overrides

There's a valid use case for enabling the timestamp downgrade check
while still also using override commits.

We'll make use of this in Fedora CoreOS, where the agent specifies the
exact commit to upgrade to, while still enforcing that it be newer.

Closes: #1891
Approved by: cgwalters

6 years agoAdd OSTREE_BUILT_FEATURES to ostree-version.h
Colin Walters [Wed, 24 Jul 2019 21:31:54 +0000 (21:31 +0000)]
Add OSTREE_BUILT_FEATURES to ostree-version.h

This way projects can dispatch at run-time based on ostree's
build time options, e.g. detect the availability of GPG.

Closes: #1890
Approved by: jlebon

6 years agoci/rpmostree: Bump to 2019.3
Dan Nicholson [Fri, 26 Jul 2019 20:28:47 +0000 (14:28 -0600)]
ci/rpmostree: Bump to 2019.3

The test-ucontainer.sh test in rpmostree 2019.1 is failing for
non-ostree reasons. This is fixed in [1], which is part of 2019.3. I
believe this is still a relevant test of f29 since that's what's shipped
in f29-updates.

1. https://github.com/projectatomic/rpm-ostree/commit/45b6186be0826889d805ba55bee3be75b042ed35

Closes: #1892
Approved by: jlebon

6 years agolib/kargs: Don't expose OstreeKernelArgs autoptr cleanup on old glib
Dan Nicholson [Fri, 26 Jul 2019 16:42:42 +0000 (10:42 -0600)]
lib/kargs: Don't expose OstreeKernelArgs autoptr cleanup on old glib

Move the OstreeKernelArgs autoptr cleanup definition to
ostree-autocleanups.h, which will only expose the definitions when
building ostree or if glib is new enough. The include of
ostree-kernel-args.h needs to be moved before ostree-autocleanups.h in
ostree.h so that the OstreeKernelArgs type is declared when the autoptr
cleanup is defined. All the places it's used already pull in libglnx.h
first so that the compat macros are picked up if glib it too old during
the ostree build.

Closes: #1892
Approved by: jlebon

6 years agotests/gpg: Skip tests when subkeys can't be expired
Dan Nicholson [Fri, 26 Jul 2019 16:11:00 +0000 (10:11 -0600)]
tests/gpg: Skip tests when subkeys can't be expired

The ability to expire subkeys using gpg's --quick-set-expire is only
available on gnupg 2.1.22. If expiring a subkey fails, assume this is
why and skip the tests that require it but run the actions that the
subsequent tests depend on. This was failing on the Debian Stretch CI
tests since stretch has gnupg 2.1.18.

Closes: #1892
Approved by: jlebon

6 years agotests/gpg: Use exit hook to kill agent in temporary GPG homedir
Dan Nicholson [Fri, 26 Jul 2019 16:17:07 +0000 (10:17 -0600)]
tests/gpg: Use exit hook to kill agent in temporary GPG homedir

This wasn't available when I originally wrote this, but it ensures that
the running gpg-agent in tmpgpghome is killed in case the tests exit
early.

Closes: #1892
Approved by: jlebon

6 years agotests/sizes.js: Fix byte array unpacking
Dan Nicholson [Mon, 8 Jul 2019 21:08:07 +0000 (15:08 -0600)]
tests/sizes.js: Fix byte array unpacking

Recent GJS changed how byte arrays are unpacked with some assumptions
that they are likely strings. Manually use get_child_value() and
get_byte() to ensure the correct value is parsed when checking the
`ostree.sizes` metadata.

The upstream test is currently passing fine with GJS 1.56.2, but at
Endless we (unfortunately) have a downstream change that adds the object
type as an additional byte in the array. This is parsed incorrectly by
`deep_unpack()`. We can carry this patch downstream, but this change
makes the test more robust regardless.

Closes: #1884
Approved by: cgwalters

6 years agotests/sizes: Fix call to commit_transaction()
Dan Nicholson [Mon, 8 Jul 2019 21:39:11 +0000 (15:39 -0600)]
tests/sizes: Fix call to commit_transaction()

The GIR for commit_transaction() only has a single argument for the
GCancellable. Calling it with 2 arguments prints a GJS warning:

Gjs-Message: 15:37:40.287: JS WARNING: [/home/dan/src/ostree/tests/test-sizes.js 56]: Too many arguments to method OSTree.Repo.commit_transaction: expected 1, got 2

Currently this is harmless, but it could become a hard error in GJS at
some point.

Closes: #1884
Approved by: cgwalters

6 years agolib/kargs: add missing function to symbol-versioning table
Rafael Fonseca [Tue, 2 Jul 2019 11:26:25 +0000 (13:26 +0200)]
lib/kargs: add missing function to symbol-versioning table

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Closes: #1883
Approved by: jlebon

6 years agolib/repo: Improve docs for get_min_free_space_bytes()
Matthew Leeds [Tue, 25 Jun 2019 23:58:38 +0000 (16:58 -0700)]
lib/repo: Improve docs for get_min_free_space_bytes()

Closes: #1879
Approved by: jlebon

6 years agolib/util: Drop unneeded ot-tool-util.h includes
Robert Fairley [Fri, 17 May 2019 18:23:41 +0000 (14:23 -0400)]
lib/util: Drop unneeded ot-tool-util.h includes

With `ot-tool-util.h` made visible in `otutil.h` (in
be2572bf68090a5e277338d2613d3c7d53b0c9e8), drop previous includes
of `ot-tool-util.h` elsewhere.

Closes: #1876
Approved by: zonggen

6 years agoci/flatpak: Bump FLATPAK_TAG to 1.4.1
Robert Fairley [Wed, 19 Jun 2019 22:22:11 +0000 (18:22 -0400)]
ci/flatpak: Bump FLATPAK_TAG to 1.4.1

Bump the flatpak version used in CI to avoid a repeated definition of
`renameat2()` in libglnx and glibc.

See: https://github.com/ostreedev/ostree/pull/1871#issuecomment-503768062

Closes: #1871
Approved by: jlebon

6 years agoMakefile-libostree.am: Work around clang issues with g-ir-scanner
Robert Fairley [Wed, 19 Jun 2019 17:32:00 +0000 (13:32 -0400)]
Makefile-libostree.am: Work around clang issues with g-ir-scanner

Work around an issue with clang-7 in Fedora 29 where the
`-fstack-clash-protection` flag is not recognized. Force
the compiler used by `g-ir-scanner` to `gcc`, so that the flag
is recognized.

Related: https://github.com/projectatomic/rpm-ostree/pull/1787#issuecomment-473971585

Closes: #1871
Approved by: jlebon

6 years agoci/build-check: Remove unused-command-line-argument diagnostic
Robert Fairley [Wed, 19 Jun 2019 20:04:39 +0000 (16:04 -0400)]
ci/build-check: Remove unused-command-line-argument diagnostic

Since `clang-4.0` is no longer being used, it should be safe to remove
use of this diagnostic for clang. This enables using `gcc` as a workaround
for `g-ir-scanner`, as `unused-command-line-argument` is not recognized by
`gcc`.

See: https://github.com/ostreedev/ostree/pull/1871#issuecomment-503765624

Closes: #1871
Approved by: jlebon

6 years agoci: Use Fedora 29 artifacts
Robert Fairley [Tue, 11 Jun 2019 20:38:16 +0000 (16:38 -0400)]
ci: Use Fedora 29 artifacts

Use Fedora 29 artifacts instead of Fedora 28, since 28 is now
end-of-life.

Also rename `ci/fah28-insttests.sh` -> `ci/fah29-insttests.sh`
and use the https://getfedora.org/atomic_qcow2_latest redirect
URL for the latest Fedora Atomic Host 29 image.

Closes: #1871
Approved by: jlebon

6 years agotests: Always cleanup gpg-agent when exiting
Dan Nicholson [Thu, 13 Jun 2019 21:26:47 +0000 (16:26 -0500)]
tests: Always cleanup gpg-agent when exiting

Add `libtest_cleanup_gpg()` to the array of commands to run when
exiting. This provides 2 improvements:

1. You don't need to worry about whether the test will spawn a gpg-agent
   and therefore require adding a call to `libtest_cleanup_gpg()`.

2. All the existing users were calling `libtest_cleanup_gpg()` at the
   end of the script. If there was a failure and the script exited
   early, then it wouldn't cleanup and there may be a stray gpg-agent
   hanging around.

Closes: #1799
Approved by: cgwalters

6 years agotests/libtest: Allow appending actions to be run on EXIT
Dan Nicholson [Thu, 13 Jun 2019 20:57:17 +0000 (15:57 -0500)]
tests/libtest: Allow appending actions to be run on EXIT

Currently if a test script adds a trap on `EXIT` to run some cleanup, it
will stomp on the existing trap to run `save_core()`. Allow for scripts
to append actions that will run on exit by introducing an array that
will be iterated over by a single exit runner.

Closes: #1799
Approved by: cgwalters

6 years agolib: Kill GPG agent when cleaning up tmp homedirs
Dan Nicholson [Thu, 10 Jan 2019 20:00:42 +0000 (14:00 -0600)]
lib: Kill GPG agent when cleaning up tmp homedirs

When a temporary directory is used for GPG operations, it's pretty clear
that the running agent will be useless after the directory is deleted.
Call the new `ot_gpgme_kill_agent ()` helper to kill gpg-agent rather
than leaving them it hanging around forever.

As it turns out, gnupg does have code to make gpg-agent automatically
exit when the homedir is removed (https://dev.gnupg.org/T2756), but
that's only available on gnupg 2.2 or newer. Possibly this code can be
dropped later when that's more widely deployed or users/distros have
been advised to backport the necessary changes.

Closes: #1799
Approved by: cgwalters

6 years agolib/gpg: Add helper to kill GPG agent
Dan Nicholson [Thu, 10 Jan 2019 19:49:17 +0000 (13:49 -0600)]
lib/gpg: Add helper to kill GPG agent

With GnuPG 2, any time you do basically any operation, a gpg-agent will
be spawned for the GPG home directory in use. The classic way to kill a
gpg-agent is to use `gpg-connect-agent` and send the `killagent` command
as is done in libtest.sh.

Closes: #1799
Approved by: cgwalters

6 years agotests/test-gpg-signed-commit: Test more key states
Dan Nicholson [Mon, 17 Jun 2019 20:25:22 +0000 (15:25 -0500)]
tests/test-gpg-signed-commit: Test more key states

Extend test-gpg-signed-commit.sh to test various key states. If gpg is
found that supports the required options, keys will be generated on the
fly and changed in various ways to exercise the output from
`ostree_gpg_verify_result_describe_variant` used in `ostree show`.

I tested this using gnupg 2.2.12, so I hope it works well enough on
various gpgs found in the wild.

Closes: #1872
Approved by: cgwalters

6 years agotests/libtest: Allow specifying GPG homedir to cleanup
Dan Nicholson [Mon, 17 Jun 2019 18:37:35 +0000 (13:37 -0500)]
tests/libtest: Allow specifying GPG homedir to cleanup

In case the tests want to use a custom GPG homedir, allow passing in the
homedir to use when cleaning up a running gpg-agent.

Closes: #1872
Approved by: cgwalters

6 years agolib/gpg: Show if GPG key has been revoked
Dan Nicholson [Mon, 10 Jun 2019 17:15:04 +0000 (12:15 -0500)]
lib/gpg: Show if GPG key has been revoked

Rather then showing the incorrect `BAD signature`.

Closes: #1872
Approved by: cgwalters

6 years agolib/gpg: Show information for expired keys
Dan Nicholson [Mon, 10 Jun 2019 17:05:21 +0000 (12:05 -0500)]
lib/gpg: Show information for expired keys

Introduce a new signature attribute for the key expiration timestamp and
display it when the key has a non-zero expiration time. Without this,
the error shown is `BAD signature`, which isn't correct.

Closes: #1872
Approved by: cgwalters

6 years agolib/gpg: Factor out expiration timestamp formatting
Dan Nicholson [Mon, 10 Jun 2019 17:01:25 +0000 (12:01 -0500)]
lib/gpg: Factor out expiration timestamp formatting

This will be reused to format a key expiration message.

Closes: #1872
Approved by: cgwalters

6 years agolib/kargs: Make API public and upstream new rpm-ostree APIs
Allen Bai [Tue, 28 May 2019 18:02:54 +0000 (14:02 -0400)]
lib/kargs: Make API public and upstream new rpm-ostree APIs

This change makes public the current kargs API in src/libostree/ostree-kernel-args.c
and adds documentations.

Upstreams the new kargs API from rpm-ostree/src/libpriv/rpmostree-kargs-process.c

Merges libostree_kernel_args_la_SOURCES to libostree_1_la_SOURCES in Makefile-libostree.am

Upstreams tests/check/test-kargs.c from rpm-ostree.

Closes: #1833
Closes: #1869
Approved by: jlebon

6 years agoadmin: allow multiple args for pin subcommand
Rafael Fonseca [Mon, 17 Jun 2019 14:41:00 +0000 (16:41 +0200)]
admin: allow multiple args for pin subcommand

Fixes #1816

Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
Closes: #1874
Approved by: rfairley

6 years agobin/refs: Allow overwriting existing ref
Dan Nicholson [Mon, 10 Jun 2019 14:47:44 +0000 (09:47 -0500)]
bin/refs: Allow overwriting existing ref

Currently if you want to update a non-alias ref, you need to first check
if it exists and use either `ostree refs --create` or `ostree reset` as
appropriate. That's unnecessarily complicated and is much less
convenient than the old `write-refs` builtin that simply called
`ostree_repo_set_ref_immediate()` without any checks.

Add a `--force` option to be used with `--create` that does not raise an
error when the destination ref already exists.

Closes: #1870
Approved by: jlebon

6 years agolib/util: Fix segfault when validating filename
Allen Bai [Wed, 5 Jun 2019 14:30:31 +0000 (10:30 -0400)]
lib/util: Fix segfault when validating filename

This change fixes the segfault issue when calling ostree_repo_checkout_tree with
empty GFileInfo. A simple condition check for NULL value is added at
src/libotutil/ot-unix-utils.c:46. Closes: ostreedev#1864.

Closes: #1868
Approved by: jlebon

6 years agoostree-repo-finder: Clarify immutability after construction
Philip Withnall [Fri, 24 May 2019 12:43:34 +0000 (13:43 +0100)]
ostree-repo-finder: Clarify immutability after construction

I think this was the intention, but I forgot to document it.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #1863
Approved by: mwleeds

6 years agotests: Test committing archives from stdin
Tristan Van Berkom [Tue, 21 May 2019 13:30:03 +0000 (22:30 +0900)]
tests: Test committing archives from stdin

This updates test-libarchive.sh to test committing archives from
stdin and verifying their content is correct.

Closes: #1862
Approved by: jlebon

6 years agoman: Document ability to commit archives from stdin
Tristan Van Berkom [Tue, 21 May 2019 13:28:19 +0000 (22:28 +0900)]
man: Document ability to commit archives from stdin

Closes: #1862
Approved by: jlebon

6 years agobin/commit: Support committing archives from stdin
Tristan Van Berkom [Tue, 21 May 2019 13:26:55 +0000 (22:26 +0900)]
bin/commit: Support committing archives from stdin

This commit interprets archive filenames specified as '-' to
indicate that the input should be read from stdin.

Closes: #1862
Approved by: jlebon

6 years agolib/commit: Added new ostree_repo_write_archive_to_mtree_from_fd()
Tristan Van Berkom [Tue, 21 May 2019 13:01:09 +0000 (22:01 +0900)]
lib/commit: Added new ostree_repo_write_archive_to_mtree_from_fd()

Similar to ostree_repo_write_archive_to_mtree(), but takes
a file descriptor to read the archive from instead of mandating
a file path.

Usefull for importing archives into an OSTree repo over a socket
or from standard input in command line tools.

Closes: #1862
Approved by: jlebon

6 years agoci: Split out installdeps.sh from build.sh
Robert Fairley [Thu, 23 May 2019 17:05:07 +0000 (13:05 -0400)]
ci: Split out installdeps.sh from build.sh

This script is useful to run individually when setting up a
development environment for OSTree.

Closes: #1865
Approved by: jlebon

6 years agolib/fetcher-util: Use GIOErrorEnum instead of GIOError
Robert Fairley [Wed, 8 May 2019 23:15:53 +0000 (19:15 -0400)]
lib/fetcher-util: Use GIOErrorEnum instead of GIOError

Use GIOErrorEnum as the return value for
_ostree_fetcher_http_status_code_to_io_error(), to avoid an
implicit cast from GIOError.

Closes: #1857
Approved by: cgwalters